package com.easyse.serviceparticaltasks.controller;

import com.easyse.model.DO.Task;
import com.easyse.model.vo.ResultVO;
import com.easyse.serviceparticaltasks.service.MissionService;
//import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：rc
 * @date ：Created in 2022/10/18 8:36
 * @description：任务相关的接口
 */

@RestController
@RequestMapping(value = "/tasks/missions/")

//@Api

public class TaskController {

    @Autowired
    MissionService missionService;

    // 获取小组所有的任务列表
    @GetMapping("list/{groupID}")
    public ResultVO getMissionList(@PathVariable("groupID") Integer groupID){
        return missionService.getMissionList(groupID);
    }


    // 新增任务

    @PostMapping("")
    public ResultVO addMission(@RequestBody Task task){
        // TODO 参数校验
        return missionService.addMission(task);
    }

    //修改任务信息
    @RequestMapping(value = "",method = RequestMethod.PATCH)
    public ResultVO updateMission(@RequestBody Task task){
        // TODO 参数校验 接口测试

        return missionService.updateMission(task);
    }

    //获取某一学生的所有任务
    @GetMapping("student/{userId}")
    public ResultVO getStudentMission(@PathVariable("userId") Integer userId){
        return missionService.getStudentMission(userId);
    }

    //结束任务
    @RequestMapping("end/{way}/{userID}/{taskID}")
    public ResultVO endMission(@PathVariable("way")String way,
                               @PathVariable("userID") Integer userID,
                               @PathVariable("taskID") Integer taskID,
                               @RequestParam(value = "story",required = false) String stroy){
        //TODO 参数校验
        //TODO 接口测试
        //检查way的方式 不通过直接返回错误
        return missionService.endMission(way,userID,taskID,stroy);
    }

    // TODO 最近快截止的任务
    @GetMapping("later")
    public ResultVO laterMission(){
        return  missionService.getLaterMission();
    }


/*
*
tasks/projects/{projectid}
*
<<<<<<< HEAD
* 某一学生的任务信息54
=======
* 某一学生的任务信息
>>>>>>> zky
tasks/classes/students/{id}
*
* 指派任务
*
* 完成任务
*
* 更改任务
*
*
* */
}
